
       IDENTIFICATION DIVISION.
       CLASS-ID. ACLASS AS "AClass".

       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
           .

      *--- FACTORY DEFINITION: STATIC MEMBERS OF THE CLASS -------------

       IDENTIFICATION DIVISION.
       FACTORY.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-COUNT   PIC 9(5).
       01  WS-MAX-ID  PIC 9(5).

       PROCEDURE DIVISION.

       IDENTIFICATION DIVISION.
       METHOD-ID. INCREMENT-COUNT AS "incrementCount" PRIVATE.
       PROCEDURE DIVISION.
           ADD 1 TO WS-COUNT
           ADD 1 TO WS-MAX-ID
           .
       END METHOD.

       IDENTIFICATION DIVISION.
       METHOD-ID. DECREMENT-COUNT AS "decrementCount" PRIVATE.
       PROCEDURE DIVISION.
           SUBTRACT 1 FROM WS-COUNT
           .
       END METHOD.

       IDENTIFICATION DIVISION.
       METHOD-ID. GET-MAX-ID AS "getMaxID" PRIVATE.
       LINKAGE SECTION.
       01  LS-RESULT  PIC 9(5).
       PROCEDURE DIVISION RETURNING LS-RESULT.
           MOVE WS-MAX-ID TO LS-RESULT
           .
       END METHOD.

       IDENTIFICATION DIVISION.
       METHOD-ID. GET-COUNT AS "getCount".
       LINKAGE SECTION.
       01  LS-RESULT  PIC 9(5).
       PROCEDURE DIVISION RETURNING LS-RESULT.
           MOVE WS-COUNT TO LS-RESULT
           .
       END METHOD.

       END FACTORY.

      *--- OBJECT DEFINITION: INSTANCE MEMBERS OF THE CLASS ------------

       IDENTIFICATION DIVISION.
       OBJECT.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-ID  PIC 9(5).

       PROCEDURE DIVISION.

       IDENTIFICATION DIVISION.
       METHOD-ID. NEW AS "new".
       PROCEDURE DIVISION.
           DISPLAY "Hello from instance method NEW."
           INVOKE AClass "incrementCount"
           SET WS-ID TO AClass:>getMaxID
           .
       END METHOD.

       IDENTIFICATION DIVISION.
       METHOD-ID. DISPOSE AS "dispose".
       PROCEDURE DIVISION.
           DISPLAY "Hello from instance method DISPOSE."
           INVOKE AClass "decrementCount"
           .
       END METHOD.

       IDENTIFICATION DIVISION.
       METHOD-ID. GET-ID AS "getID".
       LINKAGE SECTION.
       01  LS-RESULT  PIC 9(5).
       PROCEDURE DIVISION RETURNING LS-RESULT.
           MOVE WS-ID TO LS-RESULT
           .
       END METHOD.

       END OBJECT.
       END CLASS.
